<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/mylayer.js" type="text/javascript" charset="utf-8"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: url(/static/pic/bt.jpeg) no-repeat center;
            background-size: cover;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        form {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            /*text-align: center;*/
        }
        h2 {
            text-align: center;
        }
        .centered-container {
            text-align: center;
        }
        .logo img {
            position: absolute; /* 将图片设置为绝对定位 */
            left: 50px; /* 将图片向右偏移200px */
            top: 0; /* 将图片置于父元素的顶部 */
        }
        .title-box{
            height: 40px;
            background: url(/static/pic/fxsc-admin.png) no-repeat center;
            background-size: 100%;
        }
    </style>
</head>
<body>
    <style>
        .demo-login-container{width: 320px; margin: 21px auto 0;}
        .demo-login-other .layui-icon{position: relative; display: inline-block; margin: 0 2px; top: 2px; font-size: 26px;}
    </style>
    <div class="logo">
        <img src="../../static/pic/xx-logo.png" alt="">
    </div>
    <form class="layui-form" action="/admin?method=login" method="post">
        <div class="title-box"></div>
        <div class="demo-login-container">
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-username"></i>
                    </div>
                    <input type="text" name="account" value="" lay-verify="required" placeholder="账   号" lay-reqtext="请填写账号" autocomplete="off" class="layui-input" lay-affix="clear">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    <input type="password" name="password" value="" lay-verify="required" placeholder="密   码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <div class="layui-input-wrap">
                            <div class="layui-input-prefix">
                                <i class="layui-icon layui-icon-vercode"></i>
                            </div>
                            <input type="text" name="code" value="" lay-verify="required" placeholder="验证码" lay-reqtext="请填写验证码" autocomplete="off" class="layui-input" lay-affix="clear">
                        </div>
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="/verifyCode" onclick="this.src='/verifyCode?t='+ new Date().getTime();" width="123.5px" height="38px">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <input type="checkbox" name="autoLogin" lay-skin="primary" title="记住密码">
                <a href="/forget.jsp" style="float: right; margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid layui-bg-orange" lay-submit lay-filter="login">登录</button>
            </div>

        </div>
    </form>
    <script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/mylayer.js" type="text/javascript" charset="utf-8"></script>
    <script>
        layui.use(function(){
            var form = layui.form;
            // 提交事件
            form.on('submit(login)', function(data){
                var field = data.field; // 获取表单字段值

                // 此处可执行 Ajax 等操作
                // …
                $.post(
                    '/admin/login',
                    field,
                    function (result) {
                        console.log(result);
                        if (result.code == 0) {
                            mylayer.okUrl(result.msg, '/');
                        } else {
                            mylayer.errorMsg(result.msg);
                        }
                    },
                    'json'
                );
                return false; // 阻止默认 form 跳转
            });
        });
    </script>

</body>
</html>